package net.crowdloud.server.DatabaseAccess.user;

import net.crowdloud.server.DatabaseAccess.problem.ConvertDatabaseToProblem;
import net.crowdloud.server.DatabaseAccess.solution.ConvertDatabaseToSolution;

public class ConvertDatabaseToUser {

	public static net.crowdloud.shared.entities.User getUser(User databaseUser) {

		net.crowdloud.shared.entities.User user = new net.crowdloud.shared.entities.User();

		if (databaseUser.getUserID() != null) {

			user.setUserID(databaseUser.getUserID().getId());
		}

		user.setName(databaseUser.getName());

		user.setContact(databaseUser.getContact());

		if (databaseUser.getGroups() != null) {

			user.setGroups(databaseUser.getGroups().getValue());
		}

		user.setUserProblems(ConvertDatabaseToProblem.getProblems(databaseUser
				.getUserProblems()));

		user.setUserSolutions(ConvertDatabaseToSolution
				.getSolutions(databaseUser.getUserSolutions()));

		return user;
	}
}
